#delimit;
set more off;

cd "C:\....\Replication files";

use "ENMI - CSES replication.dta", clear;

corr ensh_mi ensh_mi_CMP;

#delimit;			
set more off;

xtreg pvote
	c.ensh_mi##1.inc_cab_l pvote_l
 , fe ;
		estimates store ES_replication;
		

	#delimit;			
set more off;

xtreg pvote
	c.ensh_mi##1.inc_cab_l c.GDPgrowth##1.inc_cab_l  pvote_l
	c.moderate##1.inc_cab_l 
, fe  ;
				estimates store ES_replication2;
				

					mat list e(b);
		mat def b = e(b);
#delimit;
xtmixed pvote
	c.ensh_mi##1.inc_cab_l c.GDPgrowth##1.inc_cab_l  pvote_l
	c.moderate##1.inc_cab_l 
	|| edate_numeric: 
		|| country:   if inc_cab_l==1, ;
		
		estimates store ES_onlyincumbents;

		
xtmixed pvote
	c.ensh_mi##1.inc_cab_l c.GDPgrowth##1.inc_cab_l  pvote_l
	c.moderate##1.inc_cab_l 
	|| edate_numeric: 
		|| country:  if inc_cab_l==0,  ;
	
		estimates store ES_onlyopposition;
		
		#delimit;
 esttab  ES_replication ES_replication2 
			using "figures\TableA3 - CSES replication.rtf", replace 
		b (%10.3f) se scalars("aic AIC" "bic BIC" "rmse RMSE" "ll Log-Likelihood" ) 
		obslast star(+ 0.10 * 0.05 ** 0.01 *** 0.001)
		label mtitles ( "Simple ENMI""Controls") nogaps
		title (\label{})
	order(ensh_mi 1.inc_cab_l 1.inc_cab_l#c.ensh_mi 
	 moderate 1.inc_cab_l#c.moderate GDPgrowth 1.inc_cab_l#c.GDPgrowth
		 pvote_l _cons )
		keep(ensh_mi 1.inc_cab_l 1.inc_cab_l#c.ensh_mi GDPgrowth 1.inc_cab_l#c.GDPgrowth moderate 1.inc_cab_l#c.moderate
		 pvote_l _cons)
		 coeflabels(
 ensh_mi "ENMI" 
1.inc_cab_l "Incumbent"
1.inc_cab_l#c.ensh_mi "Incumbent X ENMI"
GDPgrowth "GDP Growth Rate" 
1.inc_cab_l#c.GDPgrowth "Incumbent X GDP Growth Rate"
1.inc_cab_l#c.moderate  "Incumbent X Moderated Position"
moderate "Moderated Position"
pvote_l "% Vote{\sub t-1}"
_cons "Constant")
			addnotes("Note: The Dependent variable is the Effective Number of Issues.");
;
